package leecode

func maxScoreIndices(nums []int) []int {
	//先统计 1 的个数
	count1 := 0
	for _, num := range nums {
		if num == 1 {
			count1++
		}
	}
	maxSource := count1
	count0 := 0
	hashMap := make(map[int]int) //每一组的和
	hashMap[0] = maxSource
	for i := 0; i < len(nums); i++ {
		if nums[i] == 0 {
			count0++
		} else {
			count1--
		}
		temp := count0 + count1
		hashMap[i+1] = temp
		if temp > maxSource {
			maxSource = temp
		}
	}
	var result []int
	for key, value := range hashMap {
		if value == maxSource {
			result = append(result, key)
		}
	}
	return result
}
